import os
from typing import Optional

class Settings:
    # 应用基本配置
    APP_NAME: str = "小呆模型应用平台"
    VERSION: str = "1.0.0"
    DEBUG: bool = True
    
    # JWT配置
    SECRET_KEY: str = "your-secret-key-here-change-this-in-production"
    ALGORITHM: str = "HS256"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
    
    # 数据库配置
    DATABASE_URL: str = "sqlite:///./database.db"
    
    # 文件上传配置
    UPLOAD_DIR: str = "./uploads"
    MAX_FILE_SIZE: int = 50 * 1024 * 1024  # 50MB
    ALLOWED_EXTENSIONS: set = {
        "txt", "pdf", "doc", "docx", 
        "xls", "xlsx", "ppt", "pptx"
    }
    
    # Dify配置
    DIFY_API_URL: Optional[str] = None
    DIFY_API_KEY: Optional[str] = None
    DIFY_IFRAME_URL: Optional[str] = "http://localhost/chatbot/KlNmRrrewfLlvDUs"
    
    # CORS配置
    ALLOW_ORIGINS: list = ["*"]
    ALLOW_CREDENTIALS: bool = True
    ALLOW_METHODS: list = ["*"]
    ALLOW_HEADERS: list = ["*"]

    def __init__(self):
        # 确保上传目录存在
        os.makedirs(self.UPLOAD_DIR, exist_ok=True)

settings = Settings() 